<template>
  <div class="templatebox">
    <baleTable
      :tableData="tableData"
      :tableHead="tableHead"
      :isSearch="true"
      :isTableRowClick="true"
      :isExport="true"
      :tableLoading="tableLoading"
      :page="page"
      @pageSizeChange="pageSizeChange"
      @handleCurrentChange="handleCurrentChange"
      @searchMethods="searchMethods"
      @tableSortChange="tableSortChange"
      @handleRowClick="handleRowClick"
      ref="baleTable"
    >
      <template #headLeft>

      </template>
     
        <template #approval_status="{ scope }">
        <span>{{ scope.row.approval_status }}</span>
      </template>

    </baleTable>
 
  </div>
</template>

<script>
import { tableHead,  } from "./config";
import { getUserList } from "@a/user";
import baleTable from "@c/baleTable.vue";
// import tableFile from "@c/table-file.vue";
export default {
  components: {
    baleTable,
    // tableFile,
  },
  data() {
    return {
      tableHead,
      tableData: [],
      page: {
        page: 1,
        size: 25,
        total: 0,
      },
      tableLoading: false,
      searchParams: {},
      sortParams: {},
    };
  },
  mounted() {
    this.getTableData();
  },
  methods: {
    
    getTableData(params) {
      let postParams = {
        perPage: this.page.size,
        page: this.page.page,
      };

      if (params) postParams = { ...postParams, ...params };
      postParams = { ...postParams, ...this.searchParams, ...this.sortParams };
      this.tableLoading = true;
      getUserList(postParams).then((res) => {
        let { data, code } = res;

        if (code == 200) {
          this.tableData = data.data;
          this.page.total = data.total;
        }
        this.tableLoading = false;
      });
    },
    searchMethods(params) {
      this.searchParams = {};
      this.page.page = 1;
      if (params.status) {
        let status = [params.status];
        params.status = status;
      }
      this.searchParams = params;
      this.getTableData();
    },
    pageSizeChange(val) {
      this.page.size = val;
      this.getTableData();
    },
    handleCurrentChange(val) {
      this.page.page = val;
      this.getTableData();
    },
    tableSortChange(params) {
      if (params.sort_str) {
        this.sortParams = { ...this.sortParams, ...params };
      } else {
        delete this.sortParams.sort_str;
        delete this.sortParams.sort_order;
      }
      this.page.page = 1;
      this.getTableData();
    },
    handleRowClick(params) {}
  },
  filters: {
  
  },
};
</script>

<style lang="less" scoped>
.templatebox {
  height: 100%;
}
</style>
